package com.sabo.feign;

import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

@Component
public class BClientFallBack implements FallbackFactory<BClient> {

    @Override
    public BClient create(Throwable cause) {
        return new BClient() {
            @Override
            public ResponseEntity<String> err() {
                return null;
            }

            @Override
            public ResponseEntity<String> ok() {
                System.out.println(cause.toString());
                return null;
            }

            @Override
            public String sleep() {
                return "sleep fallback";
            }

            @Override
            public Integer exception(Integer a, Integer b) {
                throw new RuntimeException("exception fallback");
            }
        };
    }
}
